﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Model;
using System.Configuration;
using Ext.Net;
namespace TCDC_System.UserControl
{
    public partial class CampaignAdd : System.Web.UI.UserControl
    {
        private tcdc_mst_campaign obj;

        protected void Page_Load(object sender, EventArgs e)
        {
            obj = new tcdc_mst_campaign();
            obj.strConn = ConfigurationManager.AppSettings["ConnString"];
        }

        public void Show()
        {
            WindowCampaignAdd.Show();
        }

        protected void SaveCampaign(object sender, DirectEventArgs e)
        {
            obj.product_id = Convert.ToInt32(txt_product_id.Text);
            obj.member_type_id = Convert.ToInt32(txt_member_type_id.Text);
            obj.campaign_group_id = Convert.ToInt32(txt_campaign_group_id.Text);
            obj.campaign_name_th = txt_campaign_name_th.Text;
            obj.campaign_name_en = txt_campaign_name_en.Text;
            obj.add_year = Convert.ToInt32(txt_add_year.Text);
            obj.add_month = Convert.ToInt32(txt_add_month.Text);
            obj.price = Convert.ToDouble(txt_price.Text);
            obj.begin_date = txt_begin_date.Text;
            obj.end_date = txt_end_date.Text;
            obj.promotion_code = txt_promotion_code.Text;
            obj.promotion_public = txt_promotion_public.Text;
            obj.site_id = Convert.ToInt32(txt_site_id.Text);
            obj.insertData(obj);
            GridStore.DataSource = obj.getByObject(new tcdc_mst_campaign());
            GridStore.DataBind();
            FormPanel1.Reset();
            WindowCampaignAdd.Hide();
        }
        public Store GridStore { get; set; }
    }
}

